<admintpl file="header" />
</head>
<body>
	<div class="wrap js-check-wrap">

		<ul class="nav nav-tabs">
			<li><a href="{:U('Goods/goods_list')}">商品列表</a></li>
			<if condition="$list['id']">
			<li class="active"><a>商品编辑</a></li>
			<else/>
			<li class="active"><a>商品添加</a></li>
			</if>
		</ul>
        <form class="form-horizontal js-ajax-forms" action="{:U('Goods/goods_edit_act')}" method="post">
			<fieldset>
				<div class="tabbable">
					<div class="tab-content">
							<fieldset>
								<div class="control-group">
									<label class="control-label">商品名称</label>
									<div class="controls">
										<input type="text" name="title" value="{$list['title']|default=''}">
										<input type="hidden" name="id" value="{$list['id']|default=''}">
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">商品描述</label>
									<div class="controls">
										<input type="text" name="subtitle" value="{$list['subtitle']|default=''}">
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">额度选择</label>
									<div class="controls">
										<select id="ck_bond">
											<option value="">有无保证金</option>
											<option value="0">无保证金</option>
											<option value="1">有保证金</option>
										</select>
										<select name="amount_id" id='amount' onchange='ck()'>
											<foreach name="amount_list" item="vo">
											<php>$tpl_selected=($list['amount']==$vo['amount'] && $list['interest']==$vo['interest'] && $list['examine']==$vo['examine'] && $list['consulting']==$vo['consulting'] && $list['bond_amount']==$vo['bond_amount'])?"selected":"";</php>
											<option {$tpl_selected} value="{$vo.id}">
												{$vo.name}
												<php>
													if($vo['bond_amount']>0){
														echo '---有保证金';
													}else{
														echo '---无保证金';
													}
												</php>
											</option>
											</foreach>
										</select>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">额度</label>
									<div class="controls"><input type="text" name="amount" id='dqf' value="{$list.amount}" disabled></div>
								</div>
								<div class="control-group">
									<label class="control-label">咨询费</label>
									<div class="controls"><input type="text" name="interest" id='zxf' value="{$list.interest|default=''}" disabled></div>
								</div>
								<div class="control-group">
									<label class="control-label">审核费</label>
									<div class="controls"><input type="text" name="examine" id='shf' value="{$list.examine|default=''}" disabled></div>
								</div>
								<div class="control-group">
									<label class="control-label">顾问费</label>
									<div class="controls"><input type="text" name="consulting" id='gwf' value="{$list.consulting|default=''}" disabled></div>
								</div>
								<div class="control-group">
									<label class="control-label">保证金</label>
									<div class="controls"><input type="text" name="bond_amount" id='bzj' value="{$list.bond_amount|default=''}" disabled></div>
								</div>
								<div class="control-group">
									<label class="control-label">颜色</label>
									<div class="controls">
										<input type="text" name="color" value="{$list['color']|default=''}">*用逗号隔开
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">规格</label>
									<div class="controls">
										<input type="text" name="spec" value="{$list['spec']|default=''}">*用逗号隔开
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">商品类型</label>
									<div class="controls">
										<select name="comm_id">
										<foreach name="commodity" item="vo" key='k'>
											<option {$k==$list["comm_id"]?"selected":""} value="{$k}">{$vo}</option>
										</foreach>
										</select>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">租赁最小周期(周)</label>
									<div class="controls">
										<input type="text" name="startime" value="{$list['startime']|default=''}">
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">租赁最大周期(周)</label>
									<div class="controls">
										<input type="text" name="endtime" value="{$list['endtime']|default=''}">
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">商品banner图</label>
									<div class="controls">
										<ul id="photos" class="pic-list unstyled">
											<notempty name="list['url']">
												<foreach name="list['url']" item="vo">
												<if condition="$vo['type'] eq 2">
												<php>$img_url=sp_get_image_preview_url($vo['url']);</php>
												<li id="savedimage{$key}">
													<input id="photo-{$key}" type="hidden" name="photos_url[]" value="{$vo['url']}"> 
													<img id="photo-{$key}-preview" src="{$img_url}" style="height:36px;width: 36px;" onclick="parent.image_preview_dialog(this.src);">
													<a href="javascript:upload_one_image('图片上传','#photo-{$key}');">替换</a>
													<a href="javascript:(function(){ $('#savedimage{$key}').remove();})();">移除</a>
												</li>
												</if>
												</foreach>
											</notempty>
										</ul>
										<a href="javascript:upload_multi_image('图片上传','#photos','photos-item-wrapper');" class="btn btn-small">选择图片</a>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label">商品详情图</label>
									<div class="controls">
										<ul id="pbc" class="pic-list unstyled">
											<notempty name="list['url']">
												<foreach name="list['url']" item="vo">
												<if condition="$vo['type'] eq 3">
												<php>$img_url=sp_get_image_preview_url($vo['url']);</php>
												<li id="pbc{$key}">
													<input id="pbc-{$key}" type="hidden" name="pbc_url[]" value="{$vo['url']}"> 
													<img id="pbc-{$key}-preview" src="{$img_url}" style="height:36px;width: 36px;" onclick="parent.image_preview_dialog(this.src);">
													<a href="javascript:upload_one_image('图片上传','#pbc-{$key}');">替换</a>
													<a href="javascript:(function(){ $('#pbc{$key}').remove();})();">移除</a>
												</li>
												</if>
												</foreach>
											</notempty>
										</ul>
										<a href="javascript:upload_multi_image('图片上传','#pbc','photos-item-wrapper-bs');" class="btn btn-small">选择图片</a>
									</div>
								</div>
							</fieldset>
					</div>
				</div>

				<div class="form-actions">
					<button type="submit" class="btn btn-primary  js-ajax-submit">{:L("SAVE")}</button>
				</div>
			</fieldset>
		</form>
		
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
<script type="text/html" id="photos-item-wrapper">
<li id="savedimage{id}">
	<input id="photo-{id}" type="hidden" name="photos_url[]" value="{filepath}"> 
	<img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;" onclick="parent.image_preview_dialog(this.src);">
	<a href="javascript:upload_one_image('图片上传','#photo-{id}');">替换</a>
	<a href="javascript:(function(){$('#savedimage{id}').remove();})();">移除</a>
</li>
</script>
<script type="text/html" id="photos-item-wrapper-bs">
<li id="pbcsavedimage{id}">
	<input id="pbc-{id}" type="hidden" name="pbc_url[]" value="{filepath}"> 
	<img id="pbc-{id}-preview" src="{url}" style="height:36px;width: 36px;" onclick="parent.image_preview_dialog(this.src);">
	<a href="javascript:upload_one_image('图片上传','#pbc-{id}');">替换</a>
	<a href="javascript:(function(){$('#pbcsavedimage{id}').remove();})();">移除</a>
</li>
</script>
<script>
	$('#ck_bond').change(function(){
		if($(this).val()!=''){
			var flag = parseInt($(this).val()) === 1;
			if(flag){
				$('#amount').find('option').each(function(){
					if($(this).text().indexOf("有保证金")>0){
						$(this).show();
					}else{
						$(this).hide();
					}
				});
			}else{
				$('#amount').find('option').each(function(){
					if($(this).text().indexOf("无保证金")>0){
						$(this).show();
					}else{
						$(this).hide();
					}
				});
			}
		}
	});
	function ck(){
		var id=$("#amount").val();
		switch (id){
			<foreach name="amount_list" item="vo">
				case '{$vo.id}':
				document.getElementById('zxf').value='{$vo.interest}元';
				document.getElementById('shf').value='{$vo.examine}元';
				document.getElementById('gwf').value='{$vo.consulting}元';
				document.getElementById('dqf').value="{$vo['amount']}元";
				<php> 
				if(empty($vo['bond_amount'])){
					$vo['bond_amount']=0;
				}
				</php>
				document.getElementById('bzj').value="{$vo['bond_amount']}元";
				break;
			</foreach>
		}
	}
</script>
</body>
</html>